package response

type Response struct {
	Code    int
	Message string
	Data    interface{}
}

const (
	Success     = 0
	TypeError   = 1
	PasswdError = 2
)

var MsgMap = []string{
	Success:     "OK",
	TypeError:   "参数Type错误",
	PasswdError: "密码错误",
}

var TypeErrorR = Response{
	Code:    TypeError,
	Message: MsgMap[TypeError],
	Data:    nil,
}

var PasswdErrorR = Response{
	Code:    PasswdError,
	Message: MsgMap[PasswdError],
	Data:    nil,
}

func R(code int, msg string, data interface{}) Response {
	return Response{
		Code:    code,
		Message: msg,
		Data:    data,
	}
}

func SuccessR(data interface{}) Response {
	return Response{
		Code:    Success,
		Message: MsgMap[Success],
		Data:    data,
	}
}
